(function(){
    function Server(){
        var $serverTableCols = [
            {field: 'bussiness', title: '业务'},
            {field: 'project', title: '项目'},
            {field: 'IPs', title: 'IP地址'},
            {field: 'createDate', title: '创建时间'},
            {field: 'updateDate', title: '更新时间'},
            {
                field: 'process',
                title: '进程列表',
                formatter: function(value, row, index){
                    return [
                        '<a href="#/process/' + row.serverId + '">',
                        '<span class="label label-default">进程列表</span>',
                        '</a>'
                    ].join('');
                }
            }, {
                field: 'status', 
                title: '状态',
                formatter: function(value, row, index){
                    if(value) return '<span class="label label-success">在线</span>';
                    else return '<span class="label label-danger">离线</span>';
                }
            },
        ];
        $serverTableCols = $baseCols.concat($serverTableCols);
        var $serverTableOpts = {
            sidePagination: 'server',
            columns: $serverTableCols,
            toolbar: '#server-manager .toolbar',
            url: apiList.server.query,
        }
        Object.assign($serverTableOpts, $baseOpts);

        var breadcrumb = new Breadcurmb({
            prefix: [
                {text: '主机管理', anchor: '/task'}
            ],
            curr: '主机列表'
        });

        var MainView = Backbone.View.extend({
            // el与initialize一样是bk的关键字, 不能重命名为其它
            el: '#page-cnt',
            template:  _.template($("#tpl-server").html()),
            events: {

            },
            initialize: function() {
                // 创建面包屑视图
                this.breadcrumbView = new BreadcrumbView({
                    model: breadcrumb
                });
                this.render();
            },
            render: function(){
                this.$el.html(this.template());
                $('#server-list').bootstrapTable($serverTableOpts);
            },
        });

        var mainView = new MainView();
        console.log('server start');

    }

    app.modules.Server = Server;

})();